package android.longs.study.mytest.servert;

import java.io.IOException;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONSerializer;
import android.longs.study.base.HomeServlet;
import android.longs.study.base.ResponeModel;
import android.longs.study.mytest.service.MyTestListService;

@WebServlet("/mytest/finish")
public class FinishMyTestListServert  extends HomeServlet{

    private MyTestListService service = new MyTestListService();
    @Override
    public void doRequestFunction(HttpServletRequest request,
	    HttpServletResponse response) {

	try {

	    System.out.println(" 提交测试题 ... ");

	    String testList = service.finishFunction(request);

	    System.out.println(testList);
	    response.getWriter().write(testList);

	} catch (Exception e) {
	    System.out.println("操作异常  "+e.getMessage());
	    ResponeModel<Object> responeModel = new ResponeModel<>();
	    responeModel.code="1002";
	    responeModel.message="操作异常 "+e.getMessage();



	    String string = JSONSerializer.toJSON(responeModel).toString();
	    try {
		response.getWriter().write(string);
	    } catch (IOException e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
	    }
	}

    }



}
